package com.notecalendar.evernote;

import java.util.List;

import javax.annotation.PostConstruct;

import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransportException;

import sun.security.action.GetLongAction;

import com.evernote.edam.error.EDAMErrorCode;
import com.evernote.edam.error.EDAMNotFoundException;
import com.evernote.edam.error.EDAMSystemException;
import com.evernote.edam.error.EDAMUserException;
import com.evernote.edam.notestore.NoteEmailParameters;
import com.evernote.edam.notestore.NoteFilter;
import com.evernote.edam.notestore.NoteList;
import com.evernote.edam.notestore.NoteStore;
import com.evernote.edam.notestore.NoteStore.Client;
import com.evernote.edam.type.Note;
import com.evernote.edam.type.NoteSortOrder;
import com.evernote.edam.type.Notebook;
import com.evernote.edam.type.Resource;
import com.evernote.edam.type.SharedNotebook;
import com.evernote.edam.type.User;
import com.evernote.edam.userstore.AuthenticationResult;
import com.evernote.edam.userstore.Constants;
import com.evernote.edam.userstore.PublicUserInfo;
import com.evernote.edam.userstore.UserStore;
import com.notecalendar.evernote.exception.EvernoteBaseException;
import com.notecalendar.evernote.exception.EvernoteConsumerException;
import com.notecalendar.evernote.exception.EvernoteUserPassException;
import com.notecalendar.evernote.exception.EvernoteVersionException;
import com.notecalendar.model.Evernote_Login;

/**
 * Class for comuncation with evernote server
 * @author bcamcereijo
 *
 */
public class EvernoteUtil {
	//System log
	private Logger logger = Logger.getLogger(EvernoteUtil.class);
	
	 // NOTE: 
	  // You must change the consumer key and consumer secret to the key and secret
	  // that you received from Evernote. This sample application authenticates to
	  // Evernote using a user's username and password. As such, it requires that
	  // you have a "client" API key. If you have a "web service" API key, this
	  // sample code will not work. Instead, please try the OAuth sample code in
	  // sample/java/oauth.
	  /*private static final String consumerKey = "etc2011-08870119";//"en-edamtest";
	  private static final String consumerSecret = "b4b12248fa455330";//"0123456789abcdef";*/
	  private String consumerKey = "";
	  private String consumerSecret = "";
	  /*Consumer key: etc2011-08870119
	  Consumer secret: b4b12248fa455330*/
	  
	  
	// Once you have completed your development on our sandbox server, we will 
	  // activate your API key on our production servers. To use the production servers, 
	  // simply change "sandbox.evernote.com" to "www.evernote.com".
	  //private static final String evernoteHost = "sandbox.evernote.com";
	  private String evernoteHost = "";
	  
	  private String userStoreUrl = "https://" + evernoteHost + "/edam/user";
	  private String noteStoreUrlBase = "https://" + evernoteHost + "/edam/note/";
	  
	  
	// Change the User Agent to a string that describes your application, using 
	  // the form company name/app name and version. Using a unique user agent string 
	  // allows us to identify applications in our logs and provide you with better support. 
	  private static final String userAgent = "NoteCalendar(Java) " + 
	                                          Constants.EDAM_VERSION_MAJOR + "." + 
	                                         Constants.EDAM_VERSION_MINOR;
	 
	  
	  
	  private String authToken;
	  private String sharedAuthToken;
	  
	  private User user;
	  
	  private String username;
	  private String pass;
	  private String sharedKey;
	  
	  
	  //proxy connection
	  private boolean proxy;
	  private String proxyHost;
	  private String proxyPort;
	  
	  /**
	   * Constructor
	   */
	  public EvernoteUtil(){
	  }
	  

	  /**
	   * Create a new note on evernote system
	   * @param note data for the note. When create, a new "guid" is given to the note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @return note
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public Note createNote(Note note, String shardId) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  note = noteStore.createNote(authToken, note);
			  return note;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  
	  /**
	   * Create a new note in a specific notebook on evernote system
	   * @param note data for the note. When create, a new "guid" is given to the note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void createNoteNotebook(Note note, Notebook notebook, String shardId) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  note.setNotebookGuid(notebook.getGuid());
			  note = noteStore.createNote(authToken, note);
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Update the note information on evernote system
	   * @param note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void updateNote(Note note, String shardId) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  noteStore.updateNote(authToken, note);
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  
	  /**
	   * Return all notebooks from evernote system
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @return
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public List<Notebook> getNotebooks(String shardId, String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  return noteStore.listNotebooks(authToken);
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Return all notes from one notebook
	   * @param notebook
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @return notes from notebook
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public NoteList getNoteFromNotebooks(Notebook notebook, String shardId, String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  
			  NoteFilter filter = new NoteFilter();
		      filter.setNotebookGuid(notebook.getGuid());
		      filter.setOrder(NoteSortOrder.CREATED.getValue());
		      filter.setAscending(true);
		      
		      NoteList noteList = noteStore.findNotes(authToken, filter, 0, 1000);
		      
		      return noteList;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Return all notes from all notebooks from evernote system
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @return
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public NoteList getAllNotes(String shardId, String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  
			  NoteList totalNoteList = new NoteList();
			  
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  
			  //Get all notebooks
			  List<Notebook> notebooks = noteStore.listNotebooks(authToken);
			  
			  for(Notebook notebook:notebooks){
				  //Notes from notebook
				  NoteList tempNoteList = getNoteFromNotebooks(notebook,shardId,authToken);
				  List<Note> tempNotes = tempNoteList.getNotes();
				  
				  //add all notes to total notes list
				  //totalNoteList.setNotes(tempNotes);
				  for(Note tmpNote : tempNotes){
					  totalNoteList.addToNotes(tmpNote);
				  }
			  }
			  
			  return totalNoteList;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Find content of a note from evernote system
	   * @param note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @return content of the note
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public Note getCompleteNote(Note note, String shardId, String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  note = noteStore.getNote(authToken, note.getGuid(),true,true,true,true);
			  
			  return note;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  
	  
	 
	  
	  /**
	   * Return inactive notes from evernote system
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @return
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public NoteList getInactiveNotes(String shardId, String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  
			  NoteFilter filter = new NoteFilter();
		      filter.setInactive(true);
		      filter.setOrder(NoteSortOrder.CREATED.getValue());
		      filter.setAscending(true);
		      
		      NoteList noteList = noteStore.findNotes(authToken, filter, 0, 1000);
		      
		      return noteList;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
		  
	  
	  /**
	   * elete a note from evernote system
	   * @param note
	   * @param full true - pernament erase / false - only move to trash
	   * @param shardId id to include in the URL used to access the NoteStore 
	   * @param authToken authorization token
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void deleteNote(Note note, boolean full,String shardId,String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  note.setActive(false);
			  note = noteStore.updateNote(authToken, note);
			  //noteStore.deleteNote(authToken, note.getGuid());
			  if(full){
				  noteStore.expungeNote(authToken, note.getGuid());
			  }
			  //noteStore.expungeInactiveNotes(authToken);
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Create a new notebook into evernote system
	   * @param notebook
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void createNotebook(Notebook notebook, String shardId, String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  noteStore.createNotebook(authToken, notebook);
			  
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Delete a notebook from evernote system
	   * @param notebook
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void deleteNotebook(Notebook notebook, String shardId, String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  noteStore.expungeNotebook(authToken, notebook.getGuid());
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	 
	  
	  /**
	   * Return a shared notebook with its shared key
	   * @param sharedKey key to access to shared notebook
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @return 
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public SharedNotebook getSharedNotebook(String sharedKey,String shardId,String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client sharedNoteStore = 
				  initializeSharedNotebook(shardId,authToken,sharedKey);
			  
			  //NoteStore.Client noteStore = initializeSharedElements(shardId);
			  
			  ///SharedNotebook sharedNotebook = noteStore.getSharedNotebookByAuth(sharedAuthToken);
			  
			  //sharedAuthToken generated on "initializeSharedElements"
			  SharedNotebook sharedNotebook = sharedNoteStore.getSharedNotebookByAuth(sharedAuthToken);
			  
			  return sharedNotebook;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
  			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Return list of notes from a shared notebook on evernote system
	   * @param sharedNotebook
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @param sharedKey key to access notes on shared notebook
	   * @return
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public NoteList getSharedNotesFromSharedNotebook(SharedNotebook sharedNotebook,
			  String shardId, String authToken,String sharedKey) 
	  	throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  
			  NoteStore.Client sharedNoteStore = 
				  initializeSharedNotebook(shardId,authToken,sharedKey);
			  
			  NoteFilter filter = new NoteFilter();
		      filter.setNotebookGuid(sharedNotebook.getNotebookGuid());
		      filter.setOrder(NoteSortOrder.CREATED.getValue());
		      filter.setAscending(true);
		      
		      NoteList noteList = sharedNoteStore.findNotes(sharedAuthToken, filter, 0, 1000);
		      
		      return noteList;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Find content of a note of shared notebook from evernote system
	   * @param note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @param sharedKey key for access shared note
	   * @return content of the note
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public String getSharedNoteBookNoteContent(Note note, String shardId, String authToken, String sharedKey) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client sharedNoteStore = 
				  initializeSharedNotebook(shardId,authToken,sharedKey);
			  
			  String content = sharedNoteStore.getNoteContent(sharedAuthToken, note.getGuid());

			  return content;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	 
	  
	  /**
	   * Get a shared note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @param sharedNoteKey shared key of the note
	   * @param noteSharedGuid guid of shared note
	   * @return note
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public Note getSharedNote(String shardId, String authToken, String sharedNoteKey,String noteSharedGuid)
	  	throws EvernoteUserPassException,EvernoteBaseException{

		  try {
			  NoteStore.Client sharedNoteStore = 
				  initializeSharedNote(shardId,noteSharedGuid, sharedNoteKey);
			  Note note = sharedNoteStore.getNote(authToken, noteSharedGuid,true,true,true,true);
			  return note;
		  } catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
					  e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  /**
	   * Find content of a shared note from evernote system
	   * @param note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @param sharedKey key for access shared note
	   * @return content of the note
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public String getSharedNoteContent(String shardId, String authToken, String noteSharedGuid,
			  String sharedNoteKey) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client sharedNoteStore = 
				  initializeSharedNote(shardId,noteSharedGuid, sharedNoteKey);
			  
			  String content = sharedNoteStore.getNoteContent(authToken, noteSharedGuid);

			  return content;
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Create a shared note into a shared notebook
	   * @param note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @param sharedKey key to access shared note
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public Note createSharedNote(Note note, String shardId, String authToken,String sharedKey)
	  	throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client sharedNoteStore = 
				  initializeSharedNotebook(shardId,authToken,sharedKey);
			  note = sharedNoteStore.createNote(sharedAuthToken, note);
			  return note;
		  }catch(EDAMUserException e){
		  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  
	  /**
	   * Delete a shared note into a shared notebook
	   * @param note
	   * @param full true - permanent erase / false - only move to trash
	   * @param shardId id to include in the URL used to access the NoteStore 
	   * @param authToken authorization token
	   * @param sharedKey key to access shared note and delete
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void deleteSharedNote(Note note,boolean full,String shardId, String authToken, String sharedKey)
	  		throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client sharedNoteStore = 
				  initializeSharedNotebook(shardId,authToken,sharedKey);
			  note.setActive(false);
			  sharedNoteStore.updateNote(sharedAuthToken, note);
			  if(full){
				  sharedNoteStore.expungeNote(sharedAuthToken, note.getGuid());
			  }
			  //noteStore.expungeInactiveNotes(authToken);
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Update a shared note into a shared notebook
	   * @param note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @param sharedKey key to access a shared note and update
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void updateSharedNote(Note note,String shardId, String authToken, String sharedKey) throws EvernoteUserPassException,EvernoteBaseException{
		  try{
			  NoteStore.Client sharedNoteStore = 
				  initializeSharedNotebook(shardId,authToken,sharedKey);
			  sharedNoteStore.updateNote(sharedAuthToken, note);
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
      			  	e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	 
	  /**
	   * Send a note by email
	   * @param note note to submit
	   * @param addresses list o email address to send
	   * @param subject subject for the email
	   * @param message message to include in the email
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void emailNote(Note note,List<String> addresses,String subject,String message, String shardId, String authToken)
	  	throws EvernoteUserPassException,EvernoteBaseException{
		  /*guid	string		optional	
			note	Types.Note		optional	
			toAddresses	list<string>		optional	
			ccAddresses	list<string>		optional	
			subject	string		optional	
			message	string		optional*/
		  try{ 
			  
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  NoteEmailParameters noteEmailParam = createNoteEmailParameters(note, addresses, subject, message);
			  noteStore.emailNote(authToken, noteEmailParam);
		  }catch(EDAMUserException e){
			  //logger.error(e);
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
					  e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  
	  /**
	   * Send a shared note by email
	   * @param sharedNote note to submit
	   * @param addresses list o email address to send
	   * @param subject subject for the email
	   * @param message message to include in the email
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void emailSharedNote(Note sharedNote,List<String> addresses,String subject,
			  String message, String shardId, String authToken) throws EvernoteUserPassException,EvernoteBaseException{
		  /*guid	string		optional	
			note	Types.Note		optional	
			toAddresses	list<string>		optional	
			ccAddresses	list<string>		optional	
			subject	string		optional	
			message	string		optional*/
		  try{ 
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  NoteEmailParameters noteEmailParam = createNoteEmailParameters(sharedNote, addresses, subject, message);
			  noteStore.emailNote(authToken, noteEmailParam);
		  }catch(EDAMUserException e){
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
					  e.getErrorCode().name());
		  }catch(EDAMSystemException e){
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  }catch(EDAMNotFoundException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }catch(TException e){
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Share a note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @param noteGuid guid of note to share
	   * @return shared id to submit for the note
	   * @throws EvernoteBaseException
	   */
	  public String shareNote(String shardId, String authToken, String noteGuid)throws EvernoteUserPassException,EvernoteBaseException{
		  try {
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  String sharedId = noteStore.shareNote(authToken, noteGuid);
			  return sharedId;
		  } catch (EDAMUserException e) {
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
					  e.getErrorCode().name());
		  } catch (EDAMNotFoundException e) {
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  } catch (EDAMSystemException e) {
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  } catch (TException e) {
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Stop to share a note
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @param authToken authorization token
	   * @param noteGuid guid of note to share
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void stopSharedNote(String shardId, String authToken, String noteGuid)throws EvernoteUserPassException,EvernoteBaseException{
		  try {
			  NoteStore.Client noteStore = initNoteStore(shardId);
			  noteStore.stopSharingNote(authToken, noteGuid);

		  } catch (EDAMUserException e) {
			  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
					  e.getErrorCode().name());
		  } catch (EDAMNotFoundException e) {
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  } catch (EDAMSystemException e) {
			  throw new EvernoteBaseException(e.getErrorCode().name());
		  } catch (TException e) {
			  throw new EvernoteBaseException(e.getLocalizedMessage());
		  }
	  }
	  
	  /**
	   * Create a NoteEmailParameters instance 
	   * @param note not to submit
	   * @param addresses list o email address to send
	   * @param subject subject for the email
	   * @param message message to include in the email
	   * @return
	   */
	  private NoteEmailParameters createNoteEmailParameters(Note note, List<String> addresses,String subject,String message){
		  NoteEmailParameters noteEmailParam = new NoteEmailParameters();
		  noteEmailParam.setNote(note);
		  noteEmailParam.setToAddresses(addresses);
		  noteEmailParam.setSubject(subject);
		  noteEmailParam.setMessage(message);
		  return noteEmailParam;
	  }
	 
	/**
	 * Initialize elements for access to shared elements 
	 * @param shardId shardId id to include in the URL used to access the NoteStore
	 * @param noteGuid guid of shared note
	 * @param noteSharedKey shared key of note
	 * @return
	 * @throws EvernoteUserPassException
	 * @throws EvernoteBaseException
	 */
		private NoteStore.Client initializeSharedNote(String shardId, String noteGuid,
				String noteSharedKey) throws EvernoteUserPassException,	EvernoteBaseException {
			try {
				NoteStore.Client noteStore = initNoteStore(shardId);
							
				//Authresult from authtoken and the sharedKey
				AuthenticationResult authResult =
					noteStore.authenticateToSharedNote(noteGuid,noteSharedKey);
				return initializeSharedElements(authResult);
			}catch (EDAMUserException ex) {
				String parameter = ex.getParameter();
				EDAMErrorCode errorCode = ex.getErrorCode();

				System.err.println("Authentication failed (parameter: " + parameter
						+ " errorCode: " + errorCode + ")");

				if (errorCode == EDAMErrorCode.INVALID_AUTH) {
					if (parameter.equals("consumerKey")) {
						if (consumerKey.equals("en-edamtest")) {
							throw new EvernoteConsumerException(
									EvernoteConsumerException.EN_EDAMTEST_EXCEPTION,
									"You must replace the variables consumerKey and consumerSecret with the values you received from Evernote.");
						} else {
							throw new EvernoteConsumerException(
									EvernoteConsumerException.KEY_EXCEPTION,
									"Your consumer key was not accepted by "
											+ evernoteHost);
							// System.err.println("This sample client application requires a client API key. If you requested a web service API key, you must authenticate using OAuth as shown in sample/java/oauth");
						}
						// System.err.println("If you do not have an API Key from Evernote, you can request one from http://www.evernote.com/about/developer/api");
					} else if (parameter.equals("username")) {
						// throw new
						// Exception("You must authenticate using a username and password from "
						// + evernoteHost);
						throw new EvernoteUserPassException(
								EvernoteUserPassException.BAD_USER_EXCEPTION,
								"You must authenticate using a username and password from "
										+ evernoteHost);
						/*
						 * if (evernoteHost.equals("www.evernote.com") == false) {
						 * System.err.println(
						 * "Note that your production Evernote account will not work on "
						 * + evernoteHost + ",");System.err.println(
						 * "you must register for a separate test account at https://"
						 * + evernoteHost + "/Registration.action"); }
						 */
					} else if (parameter.equals("password")) {
						// throw new
						// Exception("The password that you entered is incorrect");
						throw new EvernoteUserPassException(
								EvernoteUserPassException.BAD_PASS_EXCEPTION,
								"The password that you entered is incorrect");
					}
				}
				throw new EvernoteBaseException(ex.getLocalizedMessage());
			}catch (EDAMSystemException edamEx) {
				throw new EvernoteBaseException(edamEx.getMessage());
			} catch (EDAMNotFoundException e) {
				throw new EvernoteBaseException(e.getLocalizedMessage());
			}catch (TException e) {
				throw new EvernoteBaseException(e.getLocalizedMessage());
			}
		}
	  
	  
		/**
		 * Initialize elements for access to shared notebook  
		 * @param shardId id to include in the URL used to access the NoteStore
		 * @param authToken authorization token
		 * sharedNotebookKey key to access a shared elements
		 * @return
		 * @throws EvernoteUserPassException
		 * @throws EvernoteBaseException
		 */
		private NoteStore.Client initializeSharedNotebook(String shardId, String authToken,
				String sharedNotebookKey) throws EvernoteUserPassException,	EvernoteBaseException {
			try {
				NoteStore.Client noteStore = initNoteStore(shardId);

				//Authresult from authtoken and the sharedKey
				AuthenticationResult authResult =
					noteStore.authenticateToSharedNotebook(sharedNotebookKey, authToken);
				return initializeSharedElements(authResult);
			}catch (EDAMUserException ex) {
				String parameter = ex.getParameter();
				EDAMErrorCode errorCode = ex.getErrorCode();

				System.err.println("Authentication failed (parameter: " + parameter
						+ " errorCode: " + errorCode + ")");

				if (errorCode == EDAMErrorCode.INVALID_AUTH) {
					if (parameter.equals("consumerKey")) {
						if (consumerKey.equals("en-edamtest")) {
							throw new EvernoteConsumerException(
									EvernoteConsumerException.EN_EDAMTEST_EXCEPTION,
							"You must replace the variables consumerKey and consumerSecret with the values you received from Evernote.");
						} else {
							throw new EvernoteConsumerException(
									EvernoteConsumerException.KEY_EXCEPTION,
									"Your consumer key was not accepted by "
									+ evernoteHost);
							// System.err.println("This sample client application requires a client API key. If you requested a web service API key, you must authenticate using OAuth as shown in sample/java/oauth");
						}
						// System.err.println("If you do not have an API Key from Evernote, you can request one from http://www.evernote.com/about/developer/api");
					} else if (parameter.equals("username")) {
						// throw new
						// Exception("You must authenticate using a username and password from "
						// + evernoteHost);
						throw new EvernoteUserPassException(
								EvernoteUserPassException.BAD_USER_EXCEPTION,
								"You must authenticate using a username and password from "
										+ evernoteHost);
						/*
						 * if (evernoteHost.equals("www.evernote.com") == false) {
						 * System.err.println(
						 * "Note that your production Evernote account will not work on "
						 * + evernoteHost + ",");System.err.println(
						 * "you must register for a separate test account at https://"
						 * + evernoteHost + "/Registration.action"); }
						 */
					} else if (parameter.equals("password")) {
						// throw new
						// Exception("The password that you entered is incorrect");
						throw new EvernoteUserPassException(
								EvernoteUserPassException.BAD_PASS_EXCEPTION,
								"The password that you entered is incorrect");
					}
				}
				throw new EvernoteBaseException(ex.getLocalizedMessage());
			}catch (EDAMSystemException edamEx) {
				throw new EvernoteBaseException(edamEx.getMessage());
			} catch (EDAMNotFoundException e) {
				throw new EvernoteBaseException(e.getLocalizedMessage());
			}catch (TException e) {
				throw new EvernoteBaseException(e.getLocalizedMessage());
			}
		}
	  
	/**
	 * Initialize elements for access to shared elements  
	 * @param authResult authentication result 
	 * @return 
	 * @throws EvernoteUserPassException
	 * @throws EvernoteBaseException
	 */
	private NoteStore.Client initializeSharedElements( AuthenticationResult authResult) 
		throws EvernoteUserPassException,	EvernoteBaseException {
		try {
			

			 // The result of a succesful authentication is an opaque authentication token
	        // that you will use in all subsequent API calls. If you are developing a
	        // web application that authenticates using OAuth, the OAuth access token
	        // that you receive would be used as the authToken in subsquent calls.
	        sharedAuthToken = authResult.getAuthenticationToken();

	        
	        // The Evernote NoteStore allows you to accessa user's notes.    
	        // In order to access the NoteStore for a given user, you need to know the 
	        // logical "shard" that their notes are stored on. The shard ID is included 
	        // in the URL used to access the NoteStore.
	        //User user = authResult.getUser();
	        PublicUserInfo pUserInfo = authResult.getPublicUserInfo();
	        //shardId = user.getShardId();
	        String shardId = pUserInfo.getShardId();
	        
	        //logger.info("Successfully authenticated as " + user.getUsername());
	        logger.info("Successfully authenticated as " + pUserInfo.getUsername());
	        
	        // Set up the NoteStore client 
	        String noteStoreUrl = noteStoreUrlBase + shardId;
	        
	        THttpClient noteStoreTrans = new THttpClient(noteStoreUrl);
	        noteStoreTrans.setCustomHeader("User-Agent", userAgent);
	        
	        TBinaryProtocol noteStoreProt = new TBinaryProtocol(noteStoreTrans);
	        NoteStore.Client sharedNoteStore = new NoteStore.Client(noteStoreProt, noteStoreProt);
			return sharedNoteStore;
		
		} catch (TException e) {
			throw new EvernoteBaseException(e.getLocalizedMessage());
		}
	}
	  
	  /**
	   * Method for initializing the elements to communicate with evernote system
	   * @throws EvernoteVersionException
	   * @throws EvernoteConsumerException
	   * @throws EvernoteUserPassException
	   * @throws EvernoteBaseException
	   */
	  public void initializeElements(Evernote_Login evernote_login) throws EvernoteVersionException,
	  		EvernoteConsumerException,EvernoteUserPassException,EvernoteBaseException{
		
		setUsername(evernote_login.getEvernote_user());
		setPass(evernote_login.getEvernote_pass());
		try {
			
			//set proxy?
			if(isProxy()){
				//set proxy
				System.setProperty("proxySet","true");
			    System.setProperty("https.proxyPort",getProxyPort());
			    System.setProperty("https.proxyHost",getProxyHost());
			  }
			
			//Set up the UserStore client. The Evernote UserStore allows you to
			// authenticate a user and access some information about their account.
		    THttpClient userStoreTrans = new THttpClient(userStoreUrl);
		    userStoreTrans.setCustomHeader("User-Agent", userAgent);
		    TBinaryProtocol userStoreProt = new TBinaryProtocol(userStoreTrans);
		    UserStore.Client userStore = new UserStore.Client(userStoreProt, userStoreProt);
		    
		    // Check that we can talk to the server
		    boolean versionOk = userStore.checkVersion("Evernote EDAMDemo (Java)",
		        com.evernote.edam.userstore.Constants.EDAM_VERSION_MAJOR,
		        com.evernote.edam.userstore.Constants.EDAM_VERSION_MINOR);
		    if (!versionOk) {
		      System.err.println("Incomatible EDAM client protocol version");
		      throw new EvernoteVersionException(EvernoteVersionException.BAD_VERSION_EXCEPTION,
		    		  	"Incomatible EDAM client protocol version");
		    }
		    // Authenticate using username & password
		    AuthenticationResult authResult = 
		    	userStore.authenticate(getUsername(), getPass(), consumerKey, consumerSecret);
		    
		    // The result of a succesful authentication is an opaque authentication token
	        // that you will use in all subsequent API calls. If you are developing a
	        // web application that authenticates using OAuth, the OAuth access token
	        // that you receive would be used as the authToken in subsquent calls.
	        authToken = authResult.getAuthenticationToken();
	        
	        // The Evernote NoteStore allows you to accessa user's notes.    
	        // In order to access the NoteStore for a given user, you need to know the 
	        // logical "shard" that their notes are stored on. The shard ID is included 
	        // in the URL used to access the NoteStore.
	        user = authResult.getUser();
	        //String shardId = user.getShardId();
	        
	        logger.info("Successfully authenticated as " + user.getUsername());
	        /*
	        // Set up the NoteStore client 
	        String noteStoreUrl = noteStoreUrlBase + shardId;
	        
	        THttpClient noteStoreTrans = new THttpClient(noteStoreUrl);
	        noteStoreTrans.setCustomHeader("User-Agent", userAgent);
	        
	        TBinaryProtocol noteStoreProt = new TBinaryProtocol(noteStoreTrans);
	        noteStore = new NoteStore.Client(noteStoreProt, noteStoreProt);
	        */
	        
	    } catch (EDAMUserException ex) {
	    	 // Note that the error handling here is far more detailed than you would 
	        // provide to a real user. It is intended to give you an idea of why the 
	        // sample application isn't able to authenticate to our servers.
	        
	        // Any time that you contact us about a problem with an Evernote API, 
	        // please provide us with the exception parameter and errorcode. 
	        String parameter = ex.getParameter();
	        EDAMErrorCode errorCode = ex.getErrorCode();
	        
	        System.err.println("Authentication failed (parameter: " + parameter + " errorCode: " + errorCode + ")");
	        
	        if (errorCode == EDAMErrorCode.INVALID_AUTH) {
	          if (parameter.equals("consumerKey")) {
	            if (consumerKey.equals("en-edamtest")) {
	            	throw new EvernoteConsumerException(EvernoteConsumerException.EN_EDAMTEST_EXCEPTION,
	            			"You must replace the variables consumerKey and consumerSecret with the values you received from Evernote.");
	            } else {
	            	throw new EvernoteConsumerException(EvernoteConsumerException.KEY_EXCEPTION,
	            			"Your consumer key was not accepted by " + evernoteHost);
	              //System.err.println("This sample client application requires a client API key. If you requested a web service API key, you must authenticate using OAuth as shown in sample/java/oauth");
	            }
	            //System.err.println("If you do not have an API Key from Evernote, you can request one from http://www.evernote.com/about/developer/api");
	          } else if (parameter.equals("username")) {
	        	  //throw new Exception("You must authenticate using a username and password from " + evernoteHost);
	        	  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
	        			  	"You must authenticate using a username and password from " + evernoteHost);
	            /*if (evernoteHost.equals("www.evernote.com") == false) {
	              System.err.println("Note that your production Evernote account will not work on " + evernoteHost + ",");
	              System.err.println("you must register for a separate test account at https://" + evernoteHost + "/Registration.action");
	            }*/
	          } else if (parameter.equals("password")) {
	        	  //throw new Exception("The password that you entered is incorrect");
	        	  throw new EvernoteUserPassException(EvernoteUserPassException.BAD_PASS_EXCEPTION,
	        			  "The password that you entered is incorrect");
	          }
	        }else if(errorCode == EDAMErrorCode.DATA_REQUIRED){
	        	if (parameter.equals("username")) {
	        		throw new EvernoteUserPassException(EvernoteUserPassException.BAD_USER_EXCEPTION, 
	        			  	"You must authenticate using a username and password from " + evernoteHost);
	        	}else if (parameter.equals("password")) {
	        		throw new EvernoteUserPassException(EvernoteUserPassException.BAD_PASS_EXCEPTION,
      			  	"You must authenticate using a valida password");
	        	}
	        }
	           
	    }catch (TTransportException e){
	    	throw new EvernoteBaseException(e.getLocalizedMessage());
	    }catch (TException e){
	    	throw new EvernoteBaseException(e.getLocalizedMessage());
	    }catch(EDAMSystemException edamEx){
	    	throw new EvernoteBaseException(edamEx.getMessage());
	    }
	  }
	  
	  /**
	   * Create a notestore to access evernote data
	   * @param shardId id to include in the URL used to access the NoteStore
	   * @return
	   * @throws EvernoteBaseException
	   */
	  private NoteStore.Client initNoteStore(String shardId)throws EvernoteBaseException{
		  String noteStoreUrl = noteStoreUrlBase + shardId;
	        
        THttpClient noteStoreTrans;
		try {
			noteStoreTrans = new THttpClient(noteStoreUrl);
	        noteStoreTrans.setCustomHeader("User-Agent", userAgent);
	        
	        TBinaryProtocol noteStoreProt = new TBinaryProtocol(noteStoreTrans);
	        NoteStore.Client noteStore = new NoteStore.Client(noteStoreProt, noteStoreProt);
	        
	        return noteStore;
		} catch (TTransportException e) {
			logger.error(e);
			throw new EvernoteBaseException(e.getLocalizedMessage());
		}
	  }
	   
	    
	    /**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}


		/**
		 * @return the username
		 */
		public String getUsername() {
			return username;
		}

		/**
		 * @param username the username to set
		 */
		public void setUsername(String username) {
			this.username = username;
		}

		/**
		 * @return the pass
		 */
		public String getPass() {
			return pass;
		}

		/**
		 * @param pass the pass to set
		 */
		public void setPass(String pass) {
			this.pass = pass;
		}

		/**
		 * @return the sharedKey
		 */
		public String getSharedKey() {
			return sharedKey;
		}

		/**
		 * @param sharedKey the sharedKey to set
		 */
		public void setSharedKey(String sharedKey) {
			this.sharedKey = sharedKey;
		}
		
		/**
		 * Token for work with evernote
		 * @return
		 */
		public String getAuthToken() {
			return authToken;
		}


		public String getConsumerKey() {
			return consumerKey;
		}


		public void setConsumerKey(String consumerKey) {
			this.consumerKey = consumerKey;
		}


		public String getConsumerSecret() {
			return consumerSecret;
		}


		public void setConsumerSecret(String consumerSecret) {
			this.consumerSecret = consumerSecret;
		}


		public String getEvernoteHost() {
			return evernoteHost;
		}


		public void setEvernoteHost(String evernoteHost) {
			this.evernoteHost = evernoteHost;
			userStoreUrl = "https://" + evernoteHost + "/edam/user";
			noteStoreUrlBase = "https://" + evernoteHost + "/edam/note/";
		}


		/**
		 * @return the proxy
		 */
		public boolean isProxy() {
			return proxy;
		}


		/**
		 * @param proxy the proxy to set
		 */
		public void setProxy(boolean proxy) {
			this.proxy = proxy;
		}


		/**
		 * @return the proxyHost
		 */
		public String getProxyHost() {
			return proxyHost;
		}


		/**
		 * @param proxyHost the proxyHost to set
		 */
		public void setProxyHost(String proxyHost) {
			this.proxyHost = proxyHost;
		}


		/**
		 * @return the proxyPort
		 */
		public String getProxyPort() {
			return proxyPort;
		}


		/**
		 * @param proxyPort the proxyPort to set
		 */
		public void setProxyPort(String proxyPort) {
			this.proxyPort = proxyPort;
		}

		
		
}
